#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

typedef struct student
{
	char name[20];
	unsigned int score;
}STU;

int main(void)
{
	int n = 0;
	STU students[100];
	scanf("%d", &n);
	int i = 0;
	for (i = 0;i < n;i++)
	{
		scanf("%u %s", &students[i].score, students[i].name);
	}
	unsigned int max = students[0].score;
	for (i = 1;i < n;i++)
	{
		if (students[i].score > max)
			max = students[i].score;
	}
	for (i = 0;i < n;i++)
	{
		if (students[i].score == max)
			printf("%s\n", students[i].name);
	}
	return 0;
}